package io.renren.modules.medical.controller;


import io.renren.common.result.Result;
import io.renren.common.validator.group.AddGroup;
import io.renren.common.validator.group.UpdateGroup;
import io.renren.modules.medical.service.PatientDiseaseInformationService;
import io.renren.modules.medical.vo.medicalVo.DiseaseInfoDetailVo;
import io.renren.modules.medical.vo.medicalVo.info.DiseaseInfoSaveVo;
import lombok.RequiredArgsConstructor;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 疾病信息接口
 * @author luosheng
 * @date 2023-05-13 16:11:38
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("medical/patientDiseaseInfo")
public class PatientDiseaseInformationController {

    private final PatientDiseaseInformationService patientDiseaseInformationService;


    /**
     * 信息
     */
    @RequiresPermissions("diseaseinfo:info")
    @GetMapping("/info/{id}")
    public Result<DiseaseInfoDetailVo> info(@PathVariable("id") Long id){
        DiseaseInfoDetailVo diseaseInfoDetailVo = patientDiseaseInformationService.getDiseaseInfo(id);
        return Result.success(diseaseInfoDetailVo);
    }


    /**
     * 保存
     */
    @RequiresPermissions("diseaseinfo:save")
    @PostMapping("/save")
    public Result<Long> save(@RequestBody @Validated(AddGroup.class) DiseaseInfoSaveVo diseaseInfoSaveVo){
		Long diseaseInfoId = patientDiseaseInformationService.saveDiseaseInfo(diseaseInfoSaveVo);
        return Result.success(diseaseInfoId);
    }


    /**
     * 修改
     */
    @RequiresPermissions("diseaseinfo:update")
    @PostMapping("/update")
    public Result<String> update(@RequestBody @Validated(UpdateGroup.class) DiseaseInfoSaveVo diseaseInfoSaveVo){
		patientDiseaseInformationService.updateDiseaseInfo(diseaseInfoSaveVo);
        return Result.success(null);
    }
}
